home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 1_2002.ISO / Data / Zips / _49 Text f199605232001.psc / centerpic.txt < prev    next >
Encoding:
Text File  |  2000-11-27  |  844 b   |  31 lines

  1.  
  2. Public Sub RedrawPic(Target As PictureBox, Source As StdPicture)
  3.  
  4.     Dim PicWidth As Integer
  5.     Dim PicHeight As Integer
  6.     Dim NewWidth As Integer
  7.     Dim NewHeight As Integer
  8.     Dim CenterX As Integer
  9.     Dim CenterY As Integer
  10.     PicWidth = Source.Width / 16.763
  11.     PicHeight = Source.Height / 16.763
  12.     Aspect = PicWidth / PicHeight
  13.     If PicWidth > PicHeight Then
  14.         NewWidth = Target.Width - 240
  15.         NewHeight = Target.Width / Aspect
  16.     Else
  17.         NewWidth = Target.Height * Aspect
  18.         NewHeight = Target.Height - 240
  19.     End If
  20.     CenterX = Target.Width / 2 - NewWidth / 2
  21.     CenterY = Target.Height / 2 - NewHeight / 2
  22.     Target.PaintPicture Source, CenterX, CenterY, NewWidth, NewHeight
  23.  
  24. End Sub
  25.  
  26. Private Sub Picture1_Click()
  27.  
  28.     RedrawPic Picture1, Picture2.Picture
  29.  
  30. End Sub
  31.